import cv2
import numpy as np

cap=cv2.VideoCapture(0)

def getpos(event,x,y,flags,param):
    if event==cv2.EVENT_LBUTTONDOWN: #定义一个鼠标左键按下去的事件
        print(HSV[y,x])
        # print((x,y))

while 1:
    ret ,frame = cap.read()

    if ret:
        HSV=cv2.cvtColor(frame,cv2.COLOR_BGR2HSV)
        cv2.imshow("imageHSV",HSV)
        cv2.imshow('image',frame)
        cv2.setMouseCallback("imageHSV",getpos)
        if cv2.waitKey(1) == 27:
            break

cap.release()
cv2.destroyAllWindows() 